22. Quiz: Out to Dinner (2-10)
Directions:
Create a variable called bill
and assign it the result of 10.25 + 3.99 + 7.15
(don't perform the calculation yourself, let JavaScript do it!). Next, create a variable called tip
and assign it the result of multiplying bill
by a 15% tip rate. Finally, add the bill
and tip
together and store it into a variable called total
.
Print the total
to the JavaScript console.
Hint: 15% in decimal form is written as 0.15
_._
TIP: To print out the
total
with a dollar sign ($
) use string concatenation. To roundtotal
up by two decimal points use thetoFixed()
method. To usetoFixed()
pass it the number of decimal points you want to use. For example, iftotal
equals3.9860
, thentotal.toFixed(2)
would return3.99
.
Your Code:
Start Quiz:
/*
* Programming Quiz: Out to Dinner (2-10)
*/
// your code goes here